package com.ostrich.note.utils;


import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateTimeUtils {
    /**
     * 毫秒值--》2023.09
     * @param newlyadd
     * @return
     */
    public static String getMonth(long newlyadd){
        Date date=new Date();
        date.setTime(newlyadd*1000);
        return   new SimpleDateFormat("yyyy.MM").format(date);

    }
    /**
     * 毫秒值--》2023.09.09
     * @param newlyadd
     * @return
     */
    public static String getMonthAndDay(long newlyadd){
        Date date=new Date();
        date.setTime(newlyadd*1000);
        return   new SimpleDateFormat("yyyy.MM.dd").format(date);

    }

    /**
     * 毫秒值--》日
     * @param newlyadd
     * @return
     */
    public static String getDay(long newlyadd){
        Date date=new Date();
        date.setTime(newlyadd*1000);
        return   new SimpleDateFormat("dd").format(date);

    }

    /**
     * 毫秒值--》10:00
     * @param newlyadd
     * @return
     */
    public static String getTime(long newlyadd){
        Date date=new Date();
        date.setTime(newlyadd*1000);
        return   new SimpleDateFormat("HH:mm").format(date);
    }
    /**
     * 毫秒值--》周几
     * @param newlyadd
     * @return
     */
    public static String getWeek(long newlyadd){
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(newlyadd*1000);
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        String[] weekdays = {"/周日","/周一","/周二","/周三","/周四","/周五","/周六"};
        return weekdays[dayOfWeek-1];


    }
}
